<!DOCTYPE html>
<html class="x-admin-sm">

<head>
	<meta charset="UTF-8">
	<title>电子学会比赛管理系统</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
	<link rel="stylesheet" href="./css/font.css">
	<link rel="stylesheet" href="./css/common.css">
	<link rel="stylesheet" href="./css/xadmin.css">
	<script type="text/javascript" src="./js/abkj/match/api/signup.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/mathwork.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/grade.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/zone.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/tmatch.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/team.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/signup.js"></script>
	<script type="text/javascript" src="./js/abkj/fun_tool.js"></script>
	<script type="text/javascript" src="./js/abkj/slAjax.js"></script>
	<script src="./lib/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="./js/xadmin.js"></script>
</head>

<body>
<div class="x-nav">
	<span class="layui-breadcrumb">
			<a href="">首页</a>
			<a><cite>裁判系统</cite></a>
			<a><cite>评分管理</cite></a>
	</span>
	<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
		<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
	</a>
</div>
<div class="layui-fluid" id="content">
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md12">
			<div class="layui-card">
				<div class="layui-card-body ">
					<form class="layui-form layui-col-space5 flex" style="display: flex;">
						<!--<div class="layui-input-inline layui-show-xs-block">-->
						<!--<input class="layui-input" placeholder="开始日" name="start" id="start"></div>-->
						<!--<div class="layui-input-inline layui-show-xs-block">-->
						<!--<input class="layui-input" placeholder="截止日" name="end" id="end"></div>-->
						<div class="layui-input-inline layui-show-xs-block flex">
							<div class="mr5">赛项</div>
							<select name="project">
								<option v-for="match in matchList" :value="match.id">{{match.theme}}</option>
							</select>
						</div>
						<div class="layui-input-inline layui-show-xs-block flex">
							<div class="mr5">赛区</div>
							<select name="division">
								<option v-for="zone in zoneList" :value="zone.id">{{zone.zoneName}}</option>
							</select>
						</div>
						<div class="layui-input-inline layui-show-xs-block flex">
							<div class="mr5">组别</div>
							<select name="group">
								<option v-for="grade in gradeList" :value="grade.id">{{grade.gradeName}}</option>
							</select>
						</div>
						<div class="layui-input-inline layui-show-xs-block flex">
							<div class="mr5">评分状态</div>
							<select name="status">
								<option value="0">未评分</option>
								<option value="1">已评分</option>
								<option value="2">已发布</option>
							</select>
						</div>
						<div class="layui-input-inline layui-show-xs-block flex">
							<div class="mr5" style="width: 40px;">账号</div>
							<input type="text" name="number" placeholder="账号" autocomplete="off" class="layui-input"></div>
						<div class="layui-input-inline layui-show-xs-block">
							<button class="layui-btn" lay-submit="" lay-filter="sreach">
								<i class="layui-icon">&#xe615;</i></button>
						</div>
					</form>
				</div>
				<div class="layui-card-body"  v-cloak>
					<table class="layui-table layui-form" id="test" lay-filter="test">
						<span style="float: left">共计***条数据</span>
						<div class="layui-btn-container">
							<button class="layui-btn layui-btn-sm" style="float: right;">批量下载</button>
						</div>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script src="./js/vue.js"></script>
<script>
	var app=new Vue({
		el: '#content',
		data: {
			matchWorkList:[],
			gradeList:[],
			matchList:[],
			zoneList:[],
			signUpList:[],//报名数据
			list:[],
			status:['审核','待审核' ,'通过', '不通过'],
			participate:['审核','参赛' ,'弃权' ],
			cols: [ //表头
				{type: 'checkbox', fixed: 'left'},
				{field: 'index', title: '序号', width: 80},
				{field: 'teamId', title: '团队ID', width: 110},
				{field: 'matchName', title: '赛项', width: 110},
				{field: 'zoneName', title: '赛区', width: 110},
				{field: 'gradeName', title: '组别', width: 110},
				{field: 'videoUrl', title: '视频', width: 110,templet: function(res){
						return '<a target="_blank" href="javascript:;" class="layui-table-link">'+ '预览 ' +'</a>'
					}},
				{field: 'imgUrl', title: '图片', width: 110,templet: function(res){
						return '<a target="_blank" href="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1584797196396&di=f44772c5c75ad35de232f85399c2dd8e&imgtype=0&src=http%3A%2F%2F46.s21i-2.faidns.com%2F2841046%2F2%2FABUIABACGAAg5Ou0mQUo1pmzjwMw6Ac4lAU.jpg" class="layui-table-link">'+ '预览 ' +'</a>'
					}},
				{field: 'docUrl', title: '文档', width: 110,templet: function(res){
						return '<a target="_blank" href="javascript:;" class="layui-table-link">'+ '预览 ' +'</a>'
					}},
				{field: 'workUrl', title: '作品', width: 135,templet: function(res){
						return '<a target="_blank" href="javascript:;" class="layui-table-link">'+ '下载' +'</a>'
					}},
				{field: 'mark', title: '分数', width: 135},
				{field: 'createTime', title: '上传时间', width: 135},
				{field: 'status', title: '评分状态', width: 135, templet: '#status'},

				{field: 'operating', title: '操作', width: 135, templet: '#operating'},
			]
		},
		mounted: function() {
			var vm = this
			layui.use('form', function () {
				vm.form = layui.form;
			});
			setTimeout(function () {
				vm.form.render()
			},200)
		},
		methods:{
			opentab:function(name,url){
				//单击事件
				console.log(name)
				console.log(url)
				xadmin.add_tab(name,url)
			},

			getZoneName:function(varZoneId){
				for(var i=0; i<this.zoneList.length; ++i){
					if(this.zoneList[i].id==varZoneId){
						return this.zoneList[i].zoneName;
					}
				}
				return null;
			},
			getMatchName:function(varMatchId){
				for(var i=0; i<this.matchList.length; ++i){
					if(this.matchList[i].id == varMatchId){
						return this.matchList[i].theme;
					}
				}
				return null;
			},
			getGradeName:function(varGradeId){
				for(var i=0; i<this.matchList.length; ++i){
					if(this.matchList[i].id == varGradeId){
						return this.matchList[i].theme;
					}
				}
				return null;
			},
			loadMatchWork:function(varParam){
				MathWorkPageList(varParam,function(data){
					app.matchWorkList=data;
					var queryData = {
						in:{ // 多条件对象
				        	"attrName":"id",
				        	"data":[]
		                }
					    // page:{
					    //     current:1, //当前页数
					    //     size:10   //每页长度
					    // },
					    // cond:{ //条件
					    //     in:{ // 多条件对象
					    //     	"attrName":"id",
					    //     	"data":[]
		       //              }
					    // }
					};
					for(var i=0; i<app.matchWorkList.records.length;++i){
						queryData.in.data.push(app.matchWorkList.records[i].signupId)
					}
					if(queryData.in.data.length > 0)
						app.loadSignUpList(queryData);
				},function(status,message){

				})
			},
			getTeamInfoFromMem:function(varTeamId){
				for(var i=0; i<app.signUpList.length; ++i){
					if(app.signUpList[i].id == varTeamId){
						return app.signUpList[i];
					}
				}
				return null;
			},
			loadSignUpList:function(varParam){
				SignupqueryList(varParam,function(data){
					app.signUpList=data
					for(var i=0; i<app.matchWorkList.records.length;++i){
						//这里没写完
						var varListItem={
							id:app.matchWorkList.records[i].id,
							index:i+(app.matchWorkList.current-1)*app.matchWorkList.size,
							teamId:app.matchWorkList.records[i].signupId
						}
						var varTeamInfo = app.getTeamInfoFromMem(app.matchWorkList.records[i].signupId);
						varListItem.matchName=app.getMatchName(varTeamInfo.matchId);
						varListItem.zoneName=app.getZoneName(varTeamInfo.zoneId);
						varListItem.gradeName=app.getGradeName(varTeamInfo.groupId);
						varListItem.videoUrl=app.matchWorkList.records[i].videoUrl;
						varListItem.imgUrl=app.matchWorkList.records[i].imgUrl;
						varListItem.docUrl=app.matchWorkList.records[i].docUrl;
						varListItem.workUrl=app.matchWorkList.records[i].url;
						varListItem.createTime=app.matchWorkList.records[i].createTime;
						varListItem.mark=app.matchWorkList.records[i].mark;
						varListItem.status=app.matchWorkList.records[i].state;
						app.list.push(varListItem);
					}
				},function(status,message){
					alert(message)
				});
			},
			loadGradeList:function(){
				GradequeryList({},function(data){
					app.gradeList=data
				},function(status,message){
					alert(message)
				})
			},
			loadMatchList:function(){
				TmatchqueryList({},function(data){
					app.matchList=data
				},function(status,message){
					alert(message);
				})
			},
			loadZoneList:function(){
				var funTool = fun_tool();
				app.zoneList=funTool.getAdminZoneIds();
				// ZonequeryList({},function(data){
				// 	app.zoneList=data
				// },function(status,message){
				// 	alert(message);
				// })
			},
			getData(){
				this.loadGradeList();
				this.loadMatchList();
				this.loadZoneList();
				var queryData = {
					    page:{
					        current:1, //当前页数
					        size:10   //每页长度
					    },
					    cond:{ //条件

					    }
					};
				this.loadMatchWork(queryData);
				this.init()
			},
			init:function() {
				var that = this
				layui.use(['laypage','table'], function () {
					// var laypage = layui.laypage;
					// //执行一个laypage实例
					// laypage.render({
					// 	elem: 'test1' //注意，这里的 test1 是 ID，不用加 # 号
					// 	,count: 16 //数据总数，从服务端得到
					// });
					var table = layui.table
					//头工具栏事件
					table.render({
						elem: '#test',
						url:'',
						title: '用户数据表',
						cols: [that.cols],
						page: true,
						data: that.list,
						count:app.matchWorkList.total
					})
				})
			}
		}
	})
	window.onload=function(){
		app.getData()
	}
</script>
<script src="./js/jquery.min.js"></script>
<script type="text/html" id="status">
	<a href="javascript:;" class="layui-table-link">{{d.status === 0 ? '未评分' : '已评分'}}</a>
</script>
<script type="text/html" id="operating">
	<a href="javascript:;" onclick="xadmin.open('评分','score.html?workId='+{{d.id}},400,200)" class="layui-table-link">{{d.status === 0 ? '评分' : ''}}</a>
</script>
<script>
	$(function () {
		layui.use(['form', 'table'], function () {
			var form = layui.form
			// layer.msg('玩命卖萌中', function(){
			//   //关闭后的操作
			//   });
			//监听提交
			form.on('submit(sreach)', function (data) {
				console.log(data)
				// layer.msg(JSON.stringify(data.field), function () {
				// location.href = 'index.html'
				// })
				return false
			})
			var table = layui.table

			table.on('checkbox(test)', function(obj){ //
				console.log(obj.checked); //当前是否选中状态
				console.log(obj.data); //选中行的相关数据
				console.log(obj.type); //如果触发的是全选，则为：all，如果触发的是单选，则为：one
				console.log(table.checkStatus('test').data); // 获取表格中选中行的数据
			});
		})
	})
</script>

</html>
